home *** CD-ROM | disk | FTP | other *** search
- /*
- * JPEG Convert2.c
- *
- * Copyright (C) 1992, James H. Brunner.
- *
- * This file is part of the "JPEG Convert" program. The JPEG Convert program signature ('Ijgp')
- * and unique file types ('TARG', 'RLE ', 'PPM ') are registered with Apple by the author.
- *
- * The JPEG Convert program is an image format conversion program that utilizes the software of
- * the Independent JPEG Group. The JPEG Convert program is essentially a Macintosh user interface
- * around the Independent JPEG Group's code. The author of JPEG Convert maintains a copyright to
- * the interface software only. For conditions of distribution and use of the Independent JPEG
- * Group's software, refer to the README file contained in the Independent JPEG Group's distribution
- * package.
- *
- * (Further use of the word 'software' refers only to the source files for implementing this user
- * interface, including the resource file which does not include this comment. It does NOT refer
- * to the Independent JPEG Group's code.)
- *
- * The conditions for distribution of this software are as follows:
- * This software may be freely distributed provided that it is not distributed for profit; a
- * nominal copying fee may be charged.
- *
- * Any distribution of this software must contain all original copyright notices.
- *
- * The conditions for use of this software IN FULL are as follows:
- * This software may be used in full by any person or business provided that the person or
- * business is not seeking profits directly from the use of this software.
- *
- * The conditions for use of this software IN PART are as follows:
- * Any person or business may copy and utilize portions of this software in other products
- * provided that a note that "portions of the software are copyright by James H. Brunner"
- * is included in the software AND the resultant software is not intended to be distributed
- * for profit.
- *
- * If SOURCE for projects containing portions of this code is not to be made available
- * with the resultant programs, an additional note that "portions of the software are
- * copyright James H. Brunner" must be included in some visable user documentation.
- *
- * Bottom line: I give it away free; I don't want you selling it. You can use the source if
- * you wish, but don't sell it. If you use my work, give me credit for it.
- */
-
- /*
- * JPEG Convert2.c
- *
- * This is part 2 of the Macintosh GUI (Graphical User Interface). It is intended to be
- * compiled on a Macintosh computer with Think C. This section contains all of the code for
- * dealing with the fancy dialogs. All of the real program logic is in "JPEG Convert1.c"
- */
-
- #include "JPEG Convert.h"
-
- #include <Scrap.h>
- #include <Packages.h>
- #include <Folders.h>
-
- #define DJPEG_DLOG_ID 151
- #define CJPEG_DLOG_ID 150
- #define PREFS_DLOG_ID 250
-
- /* item IDs in the PREFs dialog (ok and cancel are predefined) */
- enum {
- kPdefault = 3,
- kPjpegT,
- kPjpegC,
- kPgifT,
- kPgifC,
- kPppmT,
- kPppmC,
- kPtargaT,
- kPtargaC,
- kPrleT,
- kPrleC,
- kPoverwrite,
- kPalltypes,
- kPok_border = 24
- };
-
- static Handle gHandleSink; /* a write only "sink" for handles */
-
- extern Boolean gNewDialogMgr; /* EXTERN: TRUE if the system 7 dialog manager is available */
- extern Boolean gAppleEvents; /* EXTERN: TRUE if the system 7 apple event facility is available */
-
- extern PrefHandle gPrefs; /* EXTERN: User prefs from preference file and/or dialog */
-
- #define PAD(s, c, l) while (s[0] < l) s[++s[0]] = c
- #define OSTYPE_TO_STR(ostype, str) do {sprintf((CSTR)str, "%.4s", &ostype); CtoPstr((CSTR)str);} while (0)
- #define STR_TO_OSTYPE(str, ostype) do {PtoCstr((PSTR)str); sscanf((CSTR)str, "%4c", &ostype); CtoPstr((CSTR)str);} while (0)
-
- /*
- * Using the name "inname", change the extension (or add it) as appropriate for the given
- * output format. (ie. if format = FMT_GIF changes infile.jpg to infile.gif) This routine
- * allows the "inname" to be a full pathname (with ':'s for directory) and will leave the
- * pathname intact in the "outname".
- */
- GLOBAL void
- fix_name (Str255 outname, Str255 inname, int format)
- {
- int i;
- int dot;
- char suffix[6];
- char *suffixp=suffix;
-
- switch (format) {
- case FMT_GIF:
- strcpy(suffix, "gif");
- break;
- case FMT_PPM:
- strcpy(suffix, "ppm");
- break;
- case FMT_RLE:
- strcpy(suffix, "rle");
- break;
- case FMT_TARGA:
- strcpy(suffix, "targa");
- break;
- case FMT_JPEG:
- strcpy(suffix, "jpg");
- break;
- default:
- outname[0] = 0;
- return;
- }
-
- BlockMove(inname, outname, inname[0]+1);
-
- for (dot=0, i=outname[0]; i > 0; i--) {
- if (outname[i] == '.') {
- dot = i;
- break;
- }
- if (outname[i] == ':')
- break;
- }
-
- if (dot == 0)
- outname[++outname[0]] = '.';
- else
- outname[0] = dot;
-
- while (*suffixp)
- outname[++outname[0]] = *suffixp++;
- }
-
-
- /*
- * This routine converts a string to a number. It returns false if the string does not
- * represent a valid positive integer (0-32767).
- */
- LOCAL Boolean
- myStringToNum (s, i)
- Str255 s;
- short *i;
- {
- long num;
- int x;
-
- for (x=1; x <= s[0]; x++)
- if (s[x] < '0' || s[x] > '9')
- return FALSE;
-
- StringToNum(s, &num);
- if (num < 0 || num > 32767)
- return FALSE;
-
- *i = (short)num;
-
- return TRUE;
- }
-
-
- /*
- * This is a shortcut for dealing with items in a dialog. All of the item routines need a
- * control handle. We have a DialogPtr and an item number.
- */
- GLOBAL Handle
- ditemh (DialogPtr theDialog, short item)
- {
- short itemt;
- Handle itemh;
- Rect itemr;
-
- GetDItem(theDialog, item, &itemt, &itemh, &itemr);
- return itemh;
- }
-
-
- /*
- * This routine is used to enable an item in a dialog box.
- */
- LOCAL void
- enableItem (theDialog, item)
- DialogPtr theDialog;
- short item;
- {
- short kind;
- Handle itemh;
- Rect itemr;
-
- GetDItem(theDialog, item, &kind, &itemh, &itemr);
- SetDItem(theDialog, item, kind & ~(short)itemDisable, itemh, &itemr);
- }
-
-
- /*
- * This routine is used to disable an item in a dialog box.
- */
- LOCAL void
- disableItem (theDialog, item)
- DialogPtr theDialog;
- short item;
- {
- short kind;
- Handle itemh;
- Rect itemr;
-
- GetDItem(theDialog, item, &kind, &itemh, &itemr);
- SetDItem(theDialog, item, kind | (short)itemDisable, itemh, &itemr);
- }
-
-
- /* This routine dims AND disables a CONTROL item in a dialog box.
- */
- LOCAL void
- dimItem (theDialog, item)
- DialogPtr theDialog;
- short item;
- {
- short kind;
- Handle itemh;
- Rect itemr;
-
- GetDItem(theDialog, item, &kind, &itemh, &itemr);
- SetDItem(theDialog, item, kind | (short)itemDisable, itemh, &itemr);
- if (kind & ctrlItem)
- HiliteControl((ControlHandle)itemh, 255);
- }
-
-
- /* This routine UNdims AND enables a CONTROL item in a dialog box.
- */
- LOCAL void
- undimItem (theDialog, item)
- DialogPtr theDialog;
- short item;
- {
- short kind;
- Handle itemh;
- Rect itemr;
-
- GetDItem(theDialog, item, &kind, &itemh, &itemr);
- SetDItem(theDialog, item, kind & ~(short)itemDisable, itemh, &itemr);
- if (kind & ctrlItem)
- HiliteControl((ControlHandle)itemh, 0);
- }
-
-
- /* This routine returns the number of characters in the selection range of the
- * current textEdit item in a dialog box. (Zero if there is a selection point.)
- */
- LOCAL short
- HasSelectionRange (DialogPeek d)
- {
- return ((*(d->textH))->selEnd - (*(d->textH))->selStart);
- }
-
-
- /* Given a character and the state of the command key, this routine determines if
- * the key is used for editing of an editText item.
- */
- LOCAL Boolean
- IsEditKey (char theKey, Boolean command)
- {
- switch (theKey) {
- case 0x1C: /* LEFT */
- case 0x1D: /* RIGHT */
- case 0x1E: /* UP */
- case 0x1F: /* DOWN */
- case 0x08: /* BACKSPACE */
- case 0x7F: /* DELETE */
- case '\t':
- return TRUE;
- break;
-
- case 'X':
- case 'x':
- case 'C':
- case 'c':
- case 'V':
- case 'v':
- return command;
- break;
-
- default:
- return FALSE;
- }
- }
-
-
- /* This routine is a NOP routine used for the OK button hiliting routine IF the
- * new dialog manager routines are in use.
- */
- GLOBAL pascal void
- NOPRoutine (WindowPtr dwind, short dinum)
- {
- }
-
-
- /* This routine defines a dialog item that borders the OK button. This is only
- * necessary if the OLD dialog manager is in use.
- */
- GLOBAL pascal void
- BorderDefault (WindowPtr dwind, short dinum)
- {
- short itemType;
- Rect borderRect;
-
- GetDItem(dwind, ok, &itemType, &gHandleSink, &borderRect);
- InsetRect(&borderRect, -4, -4);
- PenSize(3, 3);
- FrameRoundRect(&borderRect, 16, 16);
- PenSize(1, 1);
- }
-
-
- /* This routine defines a dialogItem that will "dim" the text in the DJ_Q_COLORS
- * editText item. We will do this if QUANTIZE is not checked.
- */
- METHODDEF pascal void
- DimColors (WindowPtr dwind, short dinum)
- {
- if (!GetCtlValue(CITEMH(dwind, DJ_QUANTIZE))) {
- PenState thePen;
- short itemType;
- Rect dimRect;
-
- GetPenState(&thePen);
- GetDItem(dwind, dinum, &itemType, &gHandleSink, &dimRect);
- PenMode(notPatBic);
- PenPat(gray);
- PaintRect(&dimRect);
- SetPenState(&thePen);
- }
- }
-
-
- /* Handle this return, enter, escape stuff for both versions of the dialog manager. This
- * routine returns TRUE if we should immediately return TRUE from the dialog filter.
- */
- GLOBAL Boolean
- ReturnEnterEscape (DialogPtr d, EventRecord *theEvent, short *item)
- {
- char theKey;
- Boolean command;
- Boolean useStdFilter=FALSE;
- long ticks;
-
- switch (theEvent->what) {
- case keyDown:
- case autoKey:
- theKey = theEvent->message & charCodeMask;
- command = ((theEvent->modifiers & cmdKey) != 0);
-
- if (!command)
- switch (theKey) {
- /* If we are using the OLD dialog manager, we need to handle RETURN, ENTER,
- * and ESC. These need to be mapped to the OK and CANCEL buttons.
- */
- case '\r': /* RETURN */
- case 0x03: /* ENTER */
- if (!gNewDialogMgr) {
- *item = ok;
- HiliteControl(CITEMH(d, ok), 1);
- Delay(8, &ticks);
- HiliteControl(CITEMH(d, ok), 0);
- return TRUE;
- } else
- useStdFilter = TRUE;
- break;
- case 0x1B: /* ESC */
- if (!gNewDialogMgr) {
- *item = J_CAN;
- HiliteControl(CITEMH(d, J_CAN), 1);
- Delay(8, &ticks);
- HiliteControl(CITEMH(d, J_CAN), 0);
- return TRUE;
- } else
- useStdFilter = TRUE;
- break;
- }
- }
-
- if (useStdFilter) {
- ModalFilterProcPtr theModalProc;
-
- if (GetStdFilterProc(&theModalProc) == noErr)
- return theModalProc(d, theEvent, item);
- }
-
- return FALSE;
- }
-
-
- /* This is a dialog filter for the DJPEG dialog. A lot of nifty stuff is done here!
- */
- METHODDEF pascal Boolean
- djpeg_dialog_filter (DialogPtr d, EventRecord *theEvent, short *item)
- {
-
- short itemType;
- Handle itemHandle;
- Rect itemRect;
- Point mouseLoc;
- char theKey;
- Boolean command;
- Boolean alreadyHandled=FALSE;
-
- SetPort(d);
-
- /* We need to manage the IBeam cursor for DJPEG (OLD and NEW dialog managers) because
- * we don't want an IBeam over an inactive editText item.
- */
- GetMouse(&mouseLoc);
- GetDItem(d, DJ_Q_COLORS, &itemType, &gHandleSink, &itemRect);
- if (PtInRect(mouseLoc, &itemRect))
- if (!GetCtlValue(CITEMH(d, DJ_QUANTIZE)))
- SetCursor(&arrow);
- else
- SetCursor(*GetCursor(1));
- else {
- GetDItem(d, DJ_DEBUG, &itemType, &gHandleSink, &itemRect);
- if (PtInRect(mouseLoc, &itemRect))
- SetCursor(*GetCursor(1));
- else
- SetCursor(&arrow);
- }
-
- if (ReturnEnterEscape(d, theEvent, item))
- return TRUE;
-
- switch (theEvent->what) {
- case keyDown:
- case autoKey:
- theKey = theEvent->message & charCodeMask;
- command = ((theEvent->modifiers & cmdKey) != 0);
-
- if (!command)
- switch (theKey) {
- /* New or old dialog manger, we need to handle TAB because of our funky inactive
- * editText item. If the item is inactive, me must tab over the item instead of
- * into it.
- */
- case '\t':
- switch (((DialogPeek)d)->editField + 1) {
- case DJ_Q_COLORS:
- SelIText(d, DJ_DEBUG, 0, MAXINT);
- break;
- case DJ_DEBUG:
- if (GetCtlValue(CITEMH(d, DJ_QUANTIZE)))
- SelIText(d, DJ_Q_COLORS, 0, MAXINT);
- else
- SelIText(d, DJ_DEBUG, 0, MAXINT);
- break;
- }
- alreadyHandled = TRUE;
- break;
- }
-
- if (!alreadyHandled) {
- if (!command && !IsEditKey(theKey, command))
- switch (((DialogPeek)d)->editField+1) {
- /* We only want numbers in COLORS and DEBUG, so map out the rest. */
- case DJ_Q_COLORS:
- case DJ_DEBUG:
- if ((theKey < '0') || (theKey > '9')) {
- SysBeep(1);
- alreadyHandled = TRUE;
- }
- break;
- }
-
- /* Make sure that the maximum field lengths are not exceeded! */
- if (!alreadyHandled) {
- short max_chars;
- short selection;
- long scraplen;
- long offset;
- Str63 theText;
-
- switch (((DialogPeek)d)->editField+1) {
- case DJ_Q_COLORS:
- max_chars = 3;
- break;
- case DJ_DEBUG:
- max_chars = 1;
- break;
- }
-
- selection = HasSelectionRange((DialogPeek)d);
-
- GetIText(ditemh(d, ((DialogPeek)d)->editField+1), theText);
-
- if (IsEditKey(theKey, command)) {
- if ((theKey == 'V') || (theKey == 'v')) {
- scraplen = GetScrap(NULL, 'TEXT', &offset);
- if (theText[0] + scraplen - selection > max_chars) {
- SysBeep(1);
- alreadyHandled = TRUE;
- }
- }
- } else {
- if (theText[0] + 1 - selection > max_chars) {
- SysBeep(1);
- alreadyHandled = TRUE;
- }
- }
- }
- }
- break;
-
- case mouseDown:
- /* If it's a mouseDown in our disabled editText item, ignore it. */
- if (!GetCtlValue(CITEMH(d, DJ_QUANTIZE))) {
- mouseLoc = theEvent->where;
- GlobalToLocal(&mouseLoc);
- GetDItem(d, DJ_Q_COLORS, &itemType, &gHandleSink, &itemRect);
- if (PtInRect(mouseLoc, &itemRect))
- alreadyHandled = TRUE;
- }
- break;
- }
-
- /* If we are using the NEW dialog manager, we are supposed to call the standard filter
- * proc if we did not handle the event.
- */
- if (alreadyHandled) {
- theEvent->what = nullEvent;
- return FALSE; /* tricks the dialog manager into handling a null event */
- }
-
- if (gNewDialogMgr) {
- ModalFilterProcPtr theModalProc;
-
- if (GetStdFilterProc(&theModalProc) == noErr)
- return theModalProc(d, theEvent, item);
- }
-
- return FALSE;
- }
-
-
- /* This routine diaplays and handles the dialog for jpeg files. It handles all of the dialog
- * stuff and returns data in the struct dlog_info.
- */
- GLOBAL short
- display_djpeg_dialog (FSSpec infile, djpeg_dlog_data *dlog_info)
- {
- DialogPtr d;
- Str255 itext;
- short num;
- short item;
- short itemt;
- Handle itemh;
- ControlHandle itemch;
- Rect itemr;
- Boolean userchange_outfile=FALSE;
- Boolean userwants_quantize=FALSE;
- Boolean need_replace_check=TRUE;
- Str63 tempstr;
- Str63 stdoutfile;
- FSSpec outspec;
- StandardFileReply reply;
-
- /* Supposed to call this with system 7 and apple events */
- if (gAppleEvents)
- if (AEInteractWithUser(kAEDefaultTimeout,NULL,NULL)) {
- SysBeep(0L);
- return;
- }
-
- dlog_info->format = DEFAULT_FMT;
-
- if (!gNewDialogMgr)
- CenterDialog(DJPEG_DLOG_ID, NULL);
- d = GetNewDialog(DJPEG_DLOG_ID, NULL, (WindowPtr)-1);
- SetPort(d);
-
- /* If we are using the NEW dialog manager, it will handle the OK and CANCEL keyboard
- * equivalents. It will also border the OK button for us. We don't wan't it to
- * track the cursor since we have a "disabled" editText item.
- */
- if (gNewDialogMgr) {
- SetDialogDefaultItem(d, ok);
- SetDialogCancelItem(d, J_CAN);
- SetDialogTracksCursor(d, FALSE);
-
- GetDItem(d, DJ_OKBORDER, &item, &gHandleSink, &itemr);
- SetDItem(d, DJ_OKBORDER, item, (Handle)NOPRoutine, &itemr);
- } else {
- GetDItem(d, DJ_OKBORDER, &item, &gHandleSink, &itemr);
- SetDItem(d, DJ_OKBORDER, item, (Handle)BorderDefault, &itemr);
- }
-
- /* set up the user item that dims the # of colors when quantize is off */
- GetDItem(d, DJ_DIMCOLORS, &item, &gHandleSink, &itemr);
- SetDItem(d, DJ_DIMCOLORS, item, (Handle)DimColors, &itemr);
-
- /* Fill in the dialog's input file name and generate an appropriate output file name */
- SetIText(ditemh(d, J_INFILE), infile.name);
- fix_name(stdoutfile, infile.name, dlog_info->format);
- SetIText(ditemh(d, J_OUTFILE), stdoutfile);
- outspec = infile;
- COPY(outspec.name, stdoutfile);
-
- /* Set the radio buttons for the default output format */
- for (item=DJ_GIF; item <= DJ_TARGA; item++)
- SetCtlValue(CITEMH(d,item), (item == dlog_info->format));
-
- #ifndef GIF_SUPPORTED
- dimItem(d, DJ_GIF);
- #endif
- #ifndef PPM_SUPPORTED
- dimItem(d, DJ_PPM);
- #endif
- #ifndef RLE_SUPPORTED
- dimItem(d, DJ_RLE);
- #endif
- #ifndef TARGA_SUPPORTED
- dimItem(d, DJ_TARGA);
- #endif
- #ifndef QUANT_1PASS_SUPPORTED
- dimItem(d, DJ_Q_1PASS);
- #endif
- #ifndef BLOCK_SMOOTHING_SUPPORTED
- dimItem(d, DJ_SMOOTH);
- #endif
-
- /* If the output format is GIF, set up quantizing */
- if (dlog_info->format == FMT_GIF) {
- SetCtlValue(CITEMH(d,DJ_QUANTIZE), 1);
- disableItem(d, DJ_QUANTIZE);
- enableItem(d, DJ_Q_COLORS);
- SelIText(d, DJ_Q_COLORS, 0, MAXINT);
- undimItem(d, DJ_Q_NODITHER);
- #ifdef QUANT_1PASS_SUPPORTED
- undimItem(d, DJ_Q_1PASS);
- #endif
- #ifndef QUANT_2PASS_SUPPORTED
- SetCtlValue(CITEMH(d,DJ_Q_1PASS), 1);
- disableItem(d, DJ_Q_1PASS);
- #endif
- } else {
- enableItem(d, DJ_QUANTIZE);
- disableItem(d, DJ_Q_COLORS);
- dimItem(d, DJ_Q_NODITHER);
- dimItem(d, DJ_Q_1PASS);
- SelIText(d, DJ_DEBUG, 0, MAXINT);
- }
-
- /* Show the dialog */
- ShowWindow((WindowPtr)d);
-
- /* Main loop for processing the user's dialog interaction */
- for (;;) {
- ModalDialog((ModalFilterProcPtr)djpeg_dialog_filter, &item);
- if (item <= J_CAN)
- break;
-
- itemh = ditemh(d,item);
- itemch = (ControlHandle)itemh;
- switch (item) {
- case J_SETFILE:
- /* We want to remember if the user has changed the default output file name */
- /* because, if they have, we can't keep changing it on them if they change */
- /* the output file format. Also, we can't handle an OK ALL any more. */
- GetIText(ditemh(d,J_OUTFILE), tempstr);
- PutFile("\pSelect output file:", tempstr, &reply);
- if (reply.sfGood) {
- outspec = reply.sfFile;
- need_replace_check = FALSE;
- SetIText(ditemh(d, J_OUTFILE), outspec.name);
-
- for (num=0, userchange_outfile=FALSE;
- !userchange_outfile && (num <= stdoutfile[0]); num++)
- if (stdoutfile[num] != outspec.name[num])
- userchange_outfile = TRUE;
-
- if (userchange_outfile)
- dimItem(d, J_OK_ALL);
- else
- undimItem(d, J_OK_ALL);
- }
- break;
-
- case DJ_GIF:
- case DJ_PPM:
- case DJ_RLE:
- case DJ_TARGA:
- /* Change current format. Fix radio buttons. */
- dlog_info->format = item;
- for (item=DJ_GIF; item <= DJ_TARGA; item++)
- SetCtlValue(CITEMH(d,item), (item == dlog_info->format));
-
- /* If they picked GIF, we must quantize (256)! */
- if (dlog_info->format == FMT_GIF) {
- SetCtlValue(CITEMH(d,DJ_QUANTIZE), 1);
- disableItem(d, DJ_QUANTIZE);
- GetIText(ditemh(d,DJ_Q_COLORS), itext);
- if (myStringToNum(itext, &num)) {
- if (num > 256) {
- SysBeep(1);
- SetIText(ditemh(d,DJ_Q_COLORS), "\p256");
- }
- } else {
- SysBeep(1);
- SetIText(ditemh(d,DJ_Q_COLORS), "\p256");
- }
- enableItem(d, DJ_Q_COLORS);
- SelIText(d, DJ_Q_COLORS, 0, MAXINT);
- GetDItem(d, DJ_Q_COLORS, &itemt, &gHandleSink, &itemr);
- InvalRect(&itemr);
- undimItem(d, DJ_Q_NODITHER);
- #ifdef QUANT_1PASS_SUPPORTED
- undimItem(d, DJ_Q_1PASS);
- #endif
- #ifndef QUANT_2PASS_SUPPORTED
- SetCtlValue(CITEMH(d,DJ_Q_1PASS), 1);
- disableItem(d, DJ_Q_1PASS);
- #endif
- } else {
- /* If they didn't pick GIF, and the only reason that quantization */
- /* is on is because WE turned it on for him, turn it off again. */
- enableItem(d, DJ_QUANTIZE);
- if (GetCtlValue(CITEMH(d, DJ_QUANTIZE)) && !userwants_quantize) {
- SetCtlValue(CITEMH(d,DJ_QUANTIZE), 0);
- disableItem(d, DJ_Q_COLORS);
- if (((DialogPeek)d)->editField+1 == DJ_Q_COLORS)
- SelIText(d, DJ_DEBUG, 0, MAXINT);
- GetDItem(d, DJ_Q_COLORS, &itemt, &gHandleSink, &itemr);
- InvalRect(&itemr);
- dimItem(d, DJ_Q_NODITHER);
- dimItem(d, DJ_Q_1PASS);
- }
- }
-
- /* If the user picked his own output file name, don't mess it up. */
- /* Otherwise, change it appropriately for the output file type. */
- if (!userchange_outfile) {
- fix_name(stdoutfile, infile.name, dlog_info->format);
- COPY(outspec.name, stdoutfile);
- SetIText(ditemh(d, J_OUTFILE), stdoutfile);
- }
- break;
-
- case DJ_QUANTIZE:
- if (GetCtlValue(itemch)) {
- /* Can't turn off quantize if GIF! */
- if (dlog_info->format == FMT_GIF)
- /* this can't be hit because cntrl is disabled */
- SysBeep(1);
- else {
- SetCtlValue(itemch, 0);
- disableItem(d, DJ_Q_COLORS);
- if (((DialogPeek)d)->editField+1 == DJ_Q_COLORS)
- SelIText(d, DJ_DEBUG, 0, MAXINT);
- GetDItem(d, DJ_Q_COLORS, &itemt, &gHandleSink, &itemr);
- InvalRect(&itemr);
- dimItem(d, DJ_Q_NODITHER);
- dimItem(d, DJ_Q_1PASS);
- userwants_quantize = FALSE;
- }
- } else {
- SetCtlValue(itemch, 1);
- GetIText(ditemh(d,DJ_Q_COLORS), itext);
- if (!myStringToNum(itext, &num)) {
- SysBeep(1);
- SetIText(ditemh(d,DJ_Q_COLORS), "\p256");
- }
- enableItem(d, DJ_Q_COLORS);
- SelIText(d, DJ_Q_COLORS, 0, MAXINT);
- GetDItem(d, DJ_Q_COLORS, &itemt, &gHandleSink, &itemr);
- InvalRect(&itemr);
- undimItem(d, DJ_Q_NODITHER);
- #ifdef QUANT_1PASS_SUPPORTED
- undimItem(d, DJ_Q_1PASS);
- #endif
- #ifndef QUANT_2PASS_SUPPORTED
- SetCtlValue(CITEMH(d,DJ_Q_1PASS), 1);
- disableItem(d, DJ_Q_1PASS);
- #endif
- userwants_quantize = TRUE;
- }
- break;
-
- case DJ_Q_COLORS:
- GetIText(itemh, itext);
- /* If invalid number, use 256 */
- if (!myStringToNum(itext, &num)) {
- SysBeep(1);
- SetIText(itemh, "\p256");
- } else
- /* GIF can't be greater than 256! */
- if (dlog_info->format == FMT_GIF && num > 256) {
- SysBeep(1);
- SetIText(itemh, "\p256");
- }
- break;
-
- case DJ_Q_1PASS:
- case DJ_Q_NODITHER:
- SetCtlValue(itemch, 1-GetCtlValue(itemch));
- userwants_quantize = TRUE;
- break;
-
- case DJ_GRAY:
- case DJ_SMOOTH:
- SetCtlValue(itemch, 1-GetCtlValue(itemch));
- break;
-
- case DJ_DEBUG:
- GetIText(itemh, itext);
- if (!myStringToNum(itext, &num)) {
- SysBeep(1);
- SetIText(itemh, "\p0");
- }
- break;
- }
- }
-
- /* If the user hit OK or OK_ALL, copy the dialog info into static vars. (Static */
- /* because they will be here on the next file if OK_ALL was hit.) */
- if (item != J_CAN) {
- dlog_info->smoothing = GetCtlValue(CITEMH(d,DJ_SMOOTH));
-
- dlog_info->grayscale = GetCtlValue(CITEMH(d,DJ_GRAY));
-
- dlog_info->quantize = GetCtlValue(CITEMH(d,DJ_QUANTIZE));
-
- GetIText(ditemh(d,DJ_Q_COLORS), itext);
- myStringToNum(itext, &(dlog_info->colors));
-
- dlog_info->onepass = GetCtlValue(CITEMH(d,DJ_Q_1PASS));
-
- dlog_info->nodither = GetCtlValue(CITEMH(d,DJ_Q_NODITHER));
-
- GetIText(ditemh(d,DJ_DEBUG), itext);
- myStringToNum(itext, &(dlog_info->debug));
-
- dlog_info->outfile = outspec;
- dlog_info->replace_ok = !need_replace_check;
- }
-
- DisposDialog(d);
- InitCursor();
-
- return item;
- }
-
-
- /* This is the dialog filter for the cjpeg dialog. It does a bunch of stuff that a filter
- * proc needs to do. It also takes care of numeric entry, etc.
- */
- METHODDEF pascal Boolean
- cjpeg_dialog_filter (DialogPtr d, EventRecord *theEvent, short *item)
- {
- short itemType;
- Handle itemHandle;
- Rect itemRect;
- Point mouseLoc;
- char theKey;
- Boolean command;
- Boolean alreadyHandled=FALSE;
-
- SetPort(d);
-
- /* If the OLD dialog manager, we have to track the cursor ourself. Otherwise, the new
- * dialog manager will do this for us.
- */
- if (!gNewDialogMgr) {
- GetMouse(&mouseLoc);
- GetDItem(d, CJ_QUALITY, &itemType, &gHandleSink, &itemRect);
- if (PtInRect(mouseLoc, &itemRect))
- SetCursor(*GetCursor(1));
- else {
- GetDItem(d, CJ_DEBUG, &itemType, &gHandleSink, &itemRect);
- if (PtInRect(mouseLoc, &itemRect))
- SetCursor(*GetCursor(1));
- else
- SetCursor(&arrow);
- }
- }
-
- if (ReturnEnterEscape(d, theEvent, item))
- return TRUE;
-
- switch (theEvent->what) {
- case keyDown:
- case autoKey:
- theKey = theEvent->message & charCodeMask;
- command = ((theEvent->modifiers & cmdKey) != 0);
-
- if (!command && !IsEditKey(theKey, command))
- switch (((DialogPeek)d)->editField+1) {
- /* CJ_QUALITY and CJ_DEBUG can only contain numbers */
- case CJ_QUALITY:
- case CJ_DEBUG:
- if ((theKey < '0') || (theKey > '9')) {
- SysBeep(1);
- alreadyHandled = TRUE;
- }
- break;
- }
-
- /* Take case of field size limits on the edit text fields */
- if (!alreadyHandled) {
- short max_chars;
- short selection;
- long scraplen;
- long offset;
- Str63 theText;
-
- switch (((DialogPeek)d)->editField+1) {
- case CJ_QUALITY:
- max_chars = 3;
- break;
- case CJ_DEBUG:
- max_chars = 1;
- break;
- }
-
- selection = HasSelectionRange((DialogPeek)d);
-
- GetIText(ditemh(d, ((DialogPeek)d)->editField+1), theText);
-
- if (IsEditKey(theKey, command)) {
- if ((theKey == 'V') || (theKey == 'v')) {
- scraplen = GetScrap(NULL, 'TEXT', &offset);
- if (theText[0] + scraplen - selection > max_chars) {
- SysBeep(1);
- alreadyHandled = TRUE;
- }
- }
- } else {
- if (theText[0] + 1 - selection > max_chars) {
- SysBeep(1);
- alreadyHandled = TRUE;
- }
- }
- }
- break;
- }
-
- /* If we have already handled the event, pass back a nullEvent to keep ModalDialog from
- * returning. Otherwise, if we are using the NEW dialog manager, we need to call the
- * standard filter proc.
- */
- if (alreadyHandled) {
- theEvent->what = nullEvent;
- return FALSE; /* tricks the dialog manager into handling a null event */
- }
-
- if (gNewDialogMgr) {
- ModalFilterProcPtr theModalProc;
-
- if (GetStdFilterProc(&theModalProc) == noErr)
- return theModalProc(d, theEvent, item);
- }
-
- return FALSE;
- }
-
-
- /* This is the routine that will display the dialog for the non-jpeg files. It returns data
- * to the caller in the dlog_info struct.
- */
- GLOBAL short
- display_cjpeg_dialog (FSSpec infile, cjpeg_dlog_data *dlog_info)
- {
- short item;
- DialogPtr d;
- Str255 itext;
- short num;
- Handle itemh;
- ControlHandle itemch;
- Rect itemr;
- Str63 tempstr;
- Str63 stdoutfile;
- Boolean need_replace_check=TRUE;
- Boolean userchange_outfile;
- FSSpec outspec;
- StandardFileReply reply;
-
- /* Supposed to call this with system 7 and apple events */
- if (gAppleEvents)
- if (AEInteractWithUser(kAEDefaultTimeout,NULL,NULL)) {
- SysBeep(0L);
- return;
- }
-
- if (!gNewDialogMgr)
- CenterDialog(CJPEG_DLOG_ID, NULL);
- d = GetNewDialog(CJPEG_DLOG_ID, NULL, (WindowPtr)-1);
- SetPort(d);
-
- /* If we are using the NEW dialog manager, it can handle the OK and CANCEL buttons.
- * It will also track our cursor for us.
- */
- if (gNewDialogMgr) {
- SetDialogDefaultItem(d, ok);
- SetDialogCancelItem(d, J_CAN);
- SetDialogTracksCursor(d, TRUE);
-
- GetDItem(d, CJ_OKBORDER, &item, (Handle *)&gHandleSink, &itemr);
- SetDItem(d, CJ_OKBORDER, item, (Handle)NOPRoutine, &itemr);
- } else {
- GetDItem(d, CJ_OKBORDER, &item, (Handle *)&gHandleSink, &itemr);
- SetDItem(d, CJ_OKBORDER, item, (Handle)BorderDefault, &itemr);
- }
-
- /* If optimization not compiled in, disable the item */
- #ifndef ENTROPY_OPT_SUPPORTED
- dimItem(d, CJ_OPT);
- #endif
- #ifndef C_ARITH_CODING_SUPPORTED
- dimItem(d, CJ_ARITH);
- #endif
- #ifndef TARGA_SUPPORTED
- dimItem(d, CJ_TARGA);
- #endif
- #ifndef C_MULTISCAN_FILES_SUPPORTED
- dimItem(d, CJ_NONINTER);
- #endif
-
- /* Fill in the dialog's input file name and generate an appropriate output file name */
- SetIText(ditemh(d, J_INFILE), infile.name);
- fix_name(stdoutfile, infile.name, FMT_JPEG);
- SetIText(ditemh(d, J_OUTFILE), stdoutfile);
- outspec = infile;
- COPY(outspec.name, stdoutfile);
-
- ShowWindow((WindowPtr)d);
-
- for (;;) {
- ModalDialog((ModalFilterProcPtr)cjpeg_dialog_filter, &item);
- if (item <= J_CAN)
- break;
-
- itemh = ditemh(d,item);
- itemch = (ControlHandle)itemh;
- switch (item) {
- case J_SETFILE:
- /* We want to remember if the user has changed the default output file name */
- /* because, if they have, we can't keep changing it on them if they change */
- /* the output file format. Also, we can't handle an OK ALL any more. */
- GetIText(ditemh(d,J_OUTFILE), tempstr);
- PutFile("\pSelect output file:", tempstr, &reply);
- if (reply.sfGood) {
- outspec = reply.sfFile;
- need_replace_check = FALSE;
- SetIText(ditemh(d, J_OUTFILE), outspec.name);
-
- for (num=0, userchange_outfile=FALSE;
- !userchange_outfile && (num <= stdoutfile[0]); num++)
- if (stdoutfile[num] != outspec.name[num])
- userchange_outfile = TRUE;
-
- if (userchange_outfile)
- dimItem(d, J_OK_ALL);
- else
- undimItem(d, J_OK_ALL);
- }
- break;
-
- case CJ_QUALITY:
- GetIText(itemh, itext);
- if (myStringToNum(itext, &num)) {
- if (num > 100) {
- SysBeep(1);
- SetIText(itemh, "\p100");
- }
- } else {
- SysBeep(1);
- SetIText(itemh, "\p75");
- }
- break;
-
- case CJ_OPT:
- case CJ_GRAY:
- case CJ_TARGA:
- case CJ_NONINTER:
- case CJ_ARITH:
- SetCtlValue(itemch, 1-GetCtlValue(itemch));
- break;
-
- case CJ_DEBUG:
- GetIText(itemh, itext);
- if (!myStringToNum(itext, &num)) {
- SysBeep(1);
- SetIText(itemh, "\p0");
- }
- break;
- }
- }
-
- /* Store dialog info in temp vars */
- if (item != J_CAN) {
- GetIText(ditemh(d,CJ_QUALITY), itext);
- myStringToNum(itext, &dlog_info->quality);
-
- dlog_info->grayscale = GetCtlValue(CITEMH(d,CJ_GRAY));
-
- dlog_info->targa = GetCtlValue(CITEMH(d,CJ_TARGA));
-
- dlog_info->optimize = GetCtlValue(CITEMH(d,CJ_OPT));
-
- dlog_info->arithmetic = GetCtlValue(CITEMH(d,CJ_ARITH));
-
- dlog_info->nointerleave = GetCtlValue(CITEMH(d, CJ_NONINTER));
-
- GetIText(ditemh(d,CJ_DEBUG), itext);
- myStringToNum(itext, &dlog_info->debug);
-
- dlog_info->outfile = outspec;
- dlog_info->replace_ok = !need_replace_check;
- }
-
- DisposDialog(d);
- InitCursor();
-
- return item;
- }
-
-
- /* set the prefs to their default values */
- LOCAL PrefHandle
- default_prefs ()
- {
- PrefHandle phand;
-
- phand = (PrefHandle)NewHandle(sizeof(prefs_data));
-
- (**phand).pref_version = PREF_VERSION;
-
- (**phand).progressLoc.h = 20;
- (**phand).progressLoc.v = 40;
-
- (**phand).jpeg_type = 'JPEG';
- (**phand).jpeg_creator = appSignature;
- (**phand).gif_type = 'GIFf';
- (**phand).gif_creator = appSignature;
- (**phand).ppm_type = 'PPM ';
- (**phand).ppm_creator = appSignature;
- (**phand).targa_type = 'TARG';
- (**phand).targa_creator = appSignature;
- (**phand).rle_type = 'RLE ';
- (**phand).rle_creator = appSignature;
-
- (**phand).overwrite = FALSE;
- (**phand).show_all = FALSE;
-
- MoveHHi((Handle)phand);
- HLock((Handle)phand);
-
- return phand;
- }
-
-
- /* This routine will read the prefs file. If a prefs file does not exist, a default prefs file
- * is created.
- */
- GLOBAL void
- read_preference_file ()
- {
- OSErr err;
- short prefsVRefNum;
- long prefsDirID;
- FSSpec prefsFSSpec;
- short prefFile;
-
- /* Think C has glue for FindFolder for system 6. So this should be OK as long as
- * the user hasn't set the "SystemSevenOrLater" define to 1. If so, it's his lunch
- * when this puppy crashes under 6.
- */
- err = FindFolder(kOnSystemDisk, kPreferencesFolderType, kCreateFolder,
- &prefsVRefNum, &prefsDirID);
- if (err != noErr) {
- Error(err, "\pError finding preferences folder", "\pUsing default prefs");
- gPrefs = default_prefs();
- return;
- }
-
- /* make a file spec for the prefs file */
- err = xFSMakeFSSpec(prefsVRefNum, prefsDirID, "\pJPEG Convert Prefs", &prefsFSSpec);
- if (err == fnfErr) {
- /* prefs file doesn't already exist, so create it */
- err = xFSpCreateResFile(&prefsFSSpec, appSignature, 'PREF', smSystemScript);
- if (err != noErr) {
- Error(err, "\pError creating a new preferences file", "\pContinuing without one");
- gPrefs = default_prefs();
- return;
- }
- }
-
- /* open the prefs file */
- prefFile = xFSpOpenResFile(&prefsFSSpec, fsRdWrPerm);
- err = ResError();
- if (err != noErr) {
- Error(err, "\pCouldn't open prefs file.", "\pPrefs will not be saved.");
- gPrefs = default_prefs();
- return;
- }
-
- /* read the resource */
- gPrefs = (PrefHandle)GetResource('PREF', 1);
- if (gPrefs == NULL) {
- gPrefs = default_prefs();
- AddResource((Handle)gPrefs, 'PREF', 1, NULL);
- err = ResError();
- if (err != noErr) {
- Error(err, "\pCouldn't create prefs resource", "\pPrefs will not be saved.");
- return;
- }
- } else {
- MoveHHi((Handle)gPrefs);
- HLock((Handle)gPrefs);
- }
-
- /* Here is where I will compare the prefs version number and update if needed */
- }
-
-
- /* This is the dialog filter for the prefs dialog. It does a bunch of stuff that a filter
- * proc needs to do. It also takes care of limited fields, etc.
- */
- METHODDEF pascal Boolean
- prefs_dialog_filter (DialogPtr d, EventRecord *theEvent, short *item)
- {
- short itemType;
- Handle itemHandle;
- Rect itemRect;
- Point mouseLoc;
- char theKey;
- Boolean command;
- Boolean alreadyHandled=FALSE;
-
- SetPort(d);
-
- /* If the OLD dialog manager, we have to track the cursor ourself. Otherwise, the new
- * dialog manager will do this for us.
- */
- if (!gNewDialogMgr) {
- GetMouse(&mouseLoc);
- GetDItem(d, kPjpegT, &itemType, &gHandleSink, &itemRect);
- if (PtInRect(mouseLoc, &itemRect))
- SetCursor(*GetCursor(1));
- else {
- GetDItem(d, kPjpegC, &itemType, &gHandleSink, &itemRect);
- if (PtInRect(mouseLoc, &itemRect))
- SetCursor(*GetCursor(1));
- else {
- GetDItem(d, kPgifT, &itemType, &gHandleSink, &itemRect);
- if (PtInRect(mouseLoc, &itemRect))
- SetCursor(*GetCursor(1));
- else {
- GetDItem(d, kPgifC, &itemType, &gHandleSink, &itemRect);
- if (PtInRect(mouseLoc, &itemRect))
- SetCursor(*GetCursor(1));
- else {
- GetDItem(d, kPppmT, &itemType, &gHandleSink, &itemRect);
- if (PtInRect(mouseLoc, &itemRect))
- SetCursor(*GetCursor(1));
- else {
- GetDItem(d, kPppmC, &itemType, &gHandleSink, &itemRect);
- if (PtInRect(mouseLoc, &itemRect))
- SetCursor(*GetCursor(1));
- else {
- GetDItem(d, kPtargaT, &itemType, &gHandleSink, &itemRect);
- if (PtInRect(mouseLoc, &itemRect))
- SetCursor(*GetCursor(1));
- else {
- GetDItem(d, kPtargaC, &itemType, &gHandleSink, &itemRect);
- if (PtInRect(mouseLoc, &itemRect))
- SetCursor(*GetCursor(1));
- else {
- GetDItem(d, kPrleT, &itemType, &gHandleSink, &itemRect);
- if (PtInRect(mouseLoc, &itemRect))
- SetCursor(*GetCursor(1));
- else {
- GetDItem(d, kPrleC, &itemType, &gHandleSink, &itemRect);
- if (PtInRect(mouseLoc, &itemRect))
- SetCursor(*GetCursor(1));
- else
- SetCursor(&arrow);
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-
- if (ReturnEnterEscape(d, theEvent, item))
- return TRUE;
-
- switch (theEvent->what) {
- short max_chars;
- short selection;
- long scraplen;
- long offset;
- Str63 theText;
-
- case keyDown:
- case autoKey:
- theKey = theEvent->message & charCodeMask;
- command = ((theEvent->modifiers & cmdKey) != 0);
-
- max_chars = 4;
-
- selection = HasSelectionRange((DialogPeek)d);
-
- GetIText(ditemh(d, ((DialogPeek)d)->editField+1), theText);
-
- if (IsEditKey(theKey, command)) {
- if ((theKey == 'V') || (theKey == 'v')) {
- scraplen = GetScrap(NULL, 'TEXT', &offset);
- if (theText[0] + scraplen - selection > max_chars) {
- SysBeep(1);
- alreadyHandled = TRUE;
- }
- }
- } else {
- if (theText[0] + 1 - selection > max_chars) {
- SysBeep(1);
- alreadyHandled = TRUE;
- }
- }
- break;
- }
-
- /* If we have already handled the event, pass back a nullEvent to keep ModalDialog from
- * returning. Otherwise, if we are using the NEW dialog manager, we need to call the
- * standard filter proc.
- */
- if (alreadyHandled) {
- theEvent->what = nullEvent;
- return FALSE; /* tricks the dialog manager into handling a null event */
- }
-
- if (gNewDialogMgr) {
- ModalFilterProcPtr theModalProc;
-
- if (GetStdFilterProc(&theModalProc) == noErr)
- return theModalProc(d, theEvent, item);
- }
-
- return FALSE;
- }
-
-
- /* This is the routine that will display the dialog for updating the prefs files. It updates the
- * global preferences struct and then re-writes the prefs file if necessary.
- */
- GLOBAL void
- display_prefs_dialog ()
- {
- short item;
- Handle itemh;
- ControlHandle itemch;
- DialogPtr d;
- Rect itemr;
- OSType sigString=appSignature;
- Str15 appString;
- Str15 tempString;
-
- /* Supposed to call this with system 7 and apple events */
- if (gAppleEvents)
- if (AEInteractWithUser(kAEDefaultTimeout,NULL,NULL)) {
- SysBeep(0L);
- return;
- }
-
- if (!gNewDialogMgr)
- CenterDialog(PREFS_DLOG_ID, NULL);
- d = GetNewDialog(PREFS_DLOG_ID, NULL, (WindowPtr)-1);
- SetPort(d);
-
- /* If we are using the NEW dialog manager, it can handle the OK and CANCEL buttons.
- * It will also track our cursor for us.
- */
- if (gNewDialogMgr) {
- SetDialogDefaultItem(d, ok);
- SetDialogCancelItem(d, cancel);
- SetDialogTracksCursor(d, TRUE);
-
- GetDItem(d, kPok_border, &item, (Handle *)&gHandleSink, &itemr);
- SetDItem(d, kPok_border, item, (Handle)NOPRoutine, &itemr);
- } else {
- GetDItem(d, kPok_border, &item, (Handle *)&gHandleSink, &itemr);
- SetDItem(d, kPok_border, item, (Handle)BorderDefault, &itemr);
- }
-
- /* Initialize the dialog to the current prefs */
- OSTYPE_TO_STR((**gPrefs).jpeg_type, tempString);
- SetIText(ditemh(d, kPjpegT), tempString);
- OSTYPE_TO_STR((**gPrefs).jpeg_creator, tempString);
- SetIText(ditemh(d, kPjpegC), tempString);
- OSTYPE_TO_STR((**gPrefs).gif_type, tempString);
- SetIText(ditemh(d, kPgifT), tempString);
- OSTYPE_TO_STR((**gPrefs).gif_creator, tempString);
- SetIText(ditemh(d, kPgifC), tempString);
- OSTYPE_TO_STR((**gPrefs).ppm_type, tempString);
- SetIText(ditemh(d, kPppmT), tempString);
- OSTYPE_TO_STR((**gPrefs).ppm_creator, tempString);
- SetIText(ditemh(d, kPppmC), tempString);
- OSTYPE_TO_STR((**gPrefs).targa_type, tempString);
- SetIText(ditemh(d, kPtargaT), tempString);
- OSTYPE_TO_STR((**gPrefs).targa_creator, tempString);
- SetIText(ditemh(d, kPtargaC), tempString);
- OSTYPE_TO_STR((**gPrefs).rle_type, tempString);
- SetIText(ditemh(d, kPrleT), tempString);
- OSTYPE_TO_STR((**gPrefs).rle_creator, tempString);
- SetIText(ditemh(d, kPrleC), tempString);
- SetCtlValue(CITEMH(d,kPoverwrite), (**gPrefs).overwrite);
- SetCtlValue(CITEMH(d,kPalltypes), (**gPrefs).show_all);
-
- SelIText(d, kPjpegT, 0, MAXINT);
-
- ShowWindow((WindowPtr)d);
-
- for (;;) {
- ModalDialog((ModalFilterProcPtr)prefs_dialog_filter, &item);
- if (item <= cancel)
- break;
-
- itemh = ditemh(d,item);
- itemch = (ControlHandle)itemh;
- switch (item) {
- case kPdefault:
- OSTYPE_TO_STR(sigString, appString);
- SetIText(ditemh(d, kPjpegT), "\pJPEG");
- SetIText(ditemh(d, kPjpegC), appString);
- SetIText(ditemh(d, kPgifT), "\pGIFf");
- SetIText(ditemh(d, kPgifC), appString);
- SetIText(ditemh(d, kPppmT), "\pPPM ");
- SetIText(ditemh(d, kPppmC), appString);
- SetIText(ditemh(d, kPtargaT), "\pTARG");
- SetIText(ditemh(d, kPtargaC), appString);
- SetIText(ditemh(d, kPrleT), "\pRLE ");
- SetIText(ditemh(d, kPrleC), appString);
- SetCtlValue(CITEMH(d,kPoverwrite), FALSE);
- SetCtlValue(CITEMH(d,kPalltypes), FALSE);
- break;
-
- case kPoverwrite:
- case kPalltypes:
- SetCtlValue(itemch, 1-GetCtlValue(itemch));
- break;
- }
- }
-
- if (item == ok) {
- GetIText(ditemh(d,kPjpegT), tempString); PAD(tempString, ' ', 4);
- STR_TO_OSTYPE(tempString, (**gPrefs).jpeg_type);
- GetIText(ditemh(d,kPjpegC), tempString); PAD(tempString, ' ', 4);
- STR_TO_OSTYPE(tempString, (**gPrefs).jpeg_creator);
-
- GetIText(ditemh(d,kPgifT), tempString); PAD(tempString, ' ', 4);
- STR_TO_OSTYPE(tempString, (**gPrefs).gif_type);
- GetIText(ditemh(d,kPgifC), tempString); PAD(tempString, ' ', 4);
- STR_TO_OSTYPE(tempString, (**gPrefs).gif_creator);
-
- GetIText(ditemh(d,kPppmT), tempString); PAD(tempString, ' ', 4);
- STR_TO_OSTYPE(tempString, (**gPrefs).ppm_type);
- GetIText(ditemh(d,kPppmC), tempString); PAD(tempString, ' ', 4);
- STR_TO_OSTYPE(tempString, (**gPrefs).ppm_creator);
-
- GetIText(ditemh(d,kPtargaT), tempString); PAD(tempString, ' ', 4);
- STR_TO_OSTYPE(tempString, (**gPrefs).targa_type);
- GetIText(ditemh(d,kPtargaC), tempString); PAD(tempString, ' ', 4);
- STR_TO_OSTYPE(tempString, (**gPrefs).targa_creator);
-
- GetIText(ditemh(d,kPrleT), tempString); PAD(tempString, ' ', 4);
- STR_TO_OSTYPE(tempString, (**gPrefs).rle_type);
- GetIText(ditemh(d,kPrleC), tempString); PAD(tempString, ' ', 4);
- STR_TO_OSTYPE(tempString, (**gPrefs).rle_creator);
-
- (**gPrefs).overwrite = GetCtlValue(CITEMH(d,kPoverwrite));
- (**gPrefs).show_all = GetCtlValue(CITEMH(d,kPalltypes));
-
- ChangedResource((Handle)gPrefs);
- }
-
- DisposDialog(d);
- InitCursor();
- }